create database STUDB;
go

use STUDB;
go

-- 创建表
create table student_info
(
    stu_no varchar(20) primary key, -- 编号
    stu_name varchar(50) not null,  -- 姓名
    stu_age int check (stu_age >= 18),  -- 年龄
    stu_sex char(2) check (stu_sex = '男' or stu_sex = '女'), -- 性别
    stu_score decimal check (stu_score > 0 and stu_score <= 100),   -- 分数
    stu_time datetime default getdate() -- 时间
);

-- 添加数据
insert into student_info values ('1', '唐僧', 22, '男', 77, '2020-01-01');
insert into student_info values ('2', '孙悟空', 20, '女', 87, '2020-02-02');
insert into student_info values ('3', '猪八戒', 21, '男', 91, '2020-03-03');
insert into student_info values ('4', '沙僧', 20, '女', 66, '2020-04-04');
insert into student_info values ('5', '白龙马', 19, '男', 83, '2020-05-05');

-- 查询表
select * from student_info;

